<?php

use yii\db\Migration;

/**
 * Class m180320_181141_user_list
 */
class m180320_181141_user_list extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {

    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        echo "m180320_181141_user_list cannot be reverted.\n";

        return false;
    }

    // Use up()/down() to run migration code without a transaction.
    public function up()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
        }

        $this->createTable('{{%user_list}}', [
            'unionid' => $this->string(200)->notNull(),
            'openId' => $this->string(200)->notNull(),
            'userid' => $this->string(200)->notNull(),
            'email' => $this->string(200)->notNull(),
            'department' => $this->string(100)->notNull(),
            'isBoss'=>$this->boolean()->notNull(),
            'order'=> $this->string(200)->notNull(),
            'dingId'=>$this->string(200)->notNull(),
            'isLeader'=>$this->boolean()->notNull(),
            'mobile'=>$this->string(50)->notNull(),
            'active'=>$this->boolean()->notNull(),
            'isAdmin'=>$this->boolean()->notNull()->defaultValue(false),
            'avatar'=>$this->string(200)->notNull(),
            'isHide'=>$this->boolean()->notNull(),
            'name'=>$this->string(100)->notNull(),
        ], $tableOptions);

    }

    public function down()
    {
        $this->dropTable('{{%user_list}}');
    }
}
